package icu.thatyear.main.config;

import icu.thatyear.main.satoken.handler.LoginHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>Project: littleShop - WebConfig
 * <p>Powered by 16423 On 2024-12-05 09:15:05
 *
 * @author 16423 [cjy]
 * @version 1.0
 * @since 17
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {
    private final LoginHandler loginHandler;

    @Autowired
    public WebConfig(LoginHandler loginHandler) {
        this.loginHandler = loginHandler;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginHandler)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/user/doLogin",
                        "/user/register",
                        "/captcha/**"
                );

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}